package com.blockmeta.bbs.minemodule.adapter;

import android.net.Uri;
import androidx.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;

import com.blockmeta.bbs.baselibrary.base.adapter.BaseAdapter;
import com.blockmeta.bbs.baselibrary.utils.TimeUtil;
import com.blockmeta.bbs.businesslibrary.util.DeepLinkUtils;
import com.blockmeta.bbs.minemodule.R;
import com.blockmeta.bbs.minemodule.pojo.SystemMessagePOJO;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by AirThor
 * Date 2018/3/13.
 * 推送系统消息
 */

public class SystemMsgAdapter extends BaseAdapter<SystemMessagePOJO,BaseViewHolder> {
    public SystemMsgAdapter(int layoutResId, @Nullable List<SystemMessagePOJO> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, final SystemMessagePOJO item) {
        String time= TimeUtil.getTimeFormatText((int) item.created);
        helper.setText(R.id.system_message_tv_time,time);
        helper.setText(R.id.system_message_tv_content,item.content);
        final View view = helper.getView(R.id.csv_container);
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TextUtils.isEmpty(item.extra.deepLink)) {
                    DeepLinkUtils.jumpToTarget(view.getContext(), Uri.parse(item.extra.deepLink));
                }
            }
        });
    }
}
